package com.tank.bean.msg;

import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.directwebremoting.annotations.DataTransferObject;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.GenericGenerator;

import com.tank.bean.User;

@DataTransferObject
@Entity
public class PmContent {
	@Override
	public String toString() {
		StringBuilder sb=new StringBuilder();
		
		
		sb.append("{");
		sb.append("id:").append(id).append(",");
		sb.append("sender:").append(sender.getName()).append(",");
		sb.append("receiptor:").append(receiptor.getName()).append(",");
		sb.append("unread:").append(unread).append(",");
		sb.append("content:").append(content).append(",");
		sb.append("remove:").append(remove).append(",");
		
		sb.append("}");
		return sb.toString();
	}
	
	@GenericGenerator(name = "gen", strategy = "increment")
	@Id
	@GeneratedValue(generator = "gen")
	private Integer id;

	@ManyToOne
	@Fetch(FetchMode.JOIN)
	private PmDialog dialog;

	@ManyToOne
	@Fetch(FetchMode.JOIN)
	private User sender;
	@ManyToOne
	@Fetch(FetchMode.JOIN)
	private User receiptor;

	@Temporal(TemporalType.TIMESTAMP)
	private Date pubtime;

	private Boolean unread;//接收者是否未读
	private String  content;
	private Integer remove;//删除标记:用户id
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public PmDialog getDialog() {
		return dialog;
	}
	public void setDialog(PmDialog dialog) {
		this.dialog = dialog;
	}
	public User getSender() {
		return sender;
	}
	public void setSender(User sender) {
		this.sender = sender;
	}
	public User getReceiptor() {
		return receiptor;
	}
	public void setReceiptor(User receiptor) {
		this.receiptor = receiptor;
	}
	public Date getPubtime() {
		return pubtime;
	}
	public void setPubtime(Date pubtime) {
		this.pubtime = pubtime;
	}
	public Boolean getUnread() {
		return unread;
	}
	public void setUnread(Boolean unread) {
		this.unread = unread;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Integer getRemove() {
		return remove;
	}
	public void setRemove(Integer remove) {
		this.remove = remove;
	}
}
